package com.sky.mapper;


import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface ShoppingCartMapper {

    /**
     * 根据条件查询购物车数据
     *
     * @param shoppingCart
     * @return
     */
    ShoppingCart findByCondition(ShoppingCart shoppingCart);

    /**
     * 添加购物车
     * @param shoppingCart
     */
    void add(ShoppingCart shoppingCart);

    /**
     * 更新购物车
     * @param shoppingCart
     */
    void update(ShoppingCart shoppingCart);

    /**
     * 根据用户id查询购物车
     * @param uid
     * @return
     */
    @Select("select * from shopping_cart where user_id = #{uid}")
    List<ShoppingCart> findByUid(Long uid);

    /**
     * 清空购物车
     * @param uid
     */
    @Delete("delete from shopping_cart where user_id = #{uid}")
    void clean(Long uid);

    /**
     * 删除购物车中的一个商品
     * @param shoppingCart
     */
    void delete(ShoppingCart shoppingCart);
}
